<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <title>Bootstrap 101 Template</title>
      <style>
	  	p{
       		fontsize:40px;
       	}		
      </style>
          
  </head>
  <body>
  
  
  
      <script type="text/javascript">
        window.onload=function(){
          $.ajax({
            type:"GET",
            url:"http://localhost:8088/CustomerSystem/showmerchant",
        }).done(function(msg){
          createmerchant(msg);
          attachevent();
      })
              
    }               
        function createmerchant(msg){
            $(msg).each(function(index,obj){
                var div=$("<div></div>");
                div.attr("id","merchant").attr("class","col-md-4");
                $("<div></div>").append($("<img/>").attr("src",obj.portrait)).appendTo(div);
                $("<p>"+obj.name+"</p>").attr("fontsize","40px").appendTo(div);
                var btndiv=$("<div></div>");
                $("<button>查看店家</button>").attr("class","operator").attr("id",obj.id).appendTo(btndiv);
                btndiv.appendTo(div);
                div.appendTo($("body"));
         
            });      
        }
          function attachevent(){
            $("button.operator").click(function(){
                var id=$(this).attr("id");
                window.location.href="http://localhost:8088/CustomerSystem/ShowFoodsByMerchant?mid="+id; 
                });
          }
     
      
      </script>
  </body>
</html>
